package com.leo.foodmaster.admin.system.service.impl;

import cn.hutool.core.util.StrUtil;
import com.leo.foodmaster.admin.system.entity.SysLoginLogEntity;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.leo.foodmaster.admin.system.entity.SysNoticeEntity;
import com.leo.foodmaster.admin.system.mapper.SysNoticeMapper;
import com.leo.foodmaster.admin.system.service.ISysNoticeService;
import lombok.AllArgsConstructor;

/**
 * 通知公告表
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2021-12-22
 */
@Service
@AllArgsConstructor
public class ISysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNoticeEntity> implements ISysNoticeService {


	@Override
	public IPage<SysNoticeEntity> pageList(Page<SysNoticeEntity> page, String noticeTitle, String createBy,
										   String noticeType, String beginTime, String endTime) {
		LambdaQueryWrapper<SysNoticeEntity> eq = Wrappers.lambdaQuery(SysNoticeEntity.class)
				.like(StrUtil.isNotBlank(noticeTitle), SysNoticeEntity::getNoticeTitle, noticeTitle)
				.like(StrUtil.isNotBlank(createBy), SysNoticeEntity::getCreateBy, createBy)
				.eq(StrUtil.isNotBlank(noticeType), SysNoticeEntity::getNoticeType, noticeType)
				.ge(StrUtil.isNotBlank(beginTime), SysNoticeEntity::getCreateTime, beginTime)
				.le(StrUtil.isNotBlank(endTime), SysNoticeEntity::getCreateTime, endTime);
		return page(new Page<>(page.getCurrent(),page.getSize()), eq);
	}
}
